package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * ip表格
 */
@Entity
@Data
@Table(name = "t_domain_wide_network_map")
public class ItDomainWideIpNetworkMap implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "int comment '唯一编号'")
    private Integer id;

    @Column(name = "wideip", columnDefinition = "varchar(128) comment '一般是CNAME'")
    private String wideip;

    @Column(name = "enabled", columnDefinition = "varchar(128) comment '状态，启用或者禁用'")
    private String enabled;

    @Column(name = "pool_name", columnDefinition = "varchar(1024) comment 'pool名称'")
    private String poolName;

    @Column(name = "pool_enabled", columnDefinition = "varchar(1024) comment 'pool状态，启用或者禁用'")
    private String poolEnabled;

    @Column(name = "members", columnDefinition = "varchar(128) comment '实际解析到的地址'")
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String members;

    @Column(name = "fallback", columnDefinition = "varchar(128) comment '一般是CNAME'")
    private String fallback;

    @Column(name = "members_enabled", columnDefinition = "varchar(128) comment '成员状态，启用或者禁用'")
    private String membersEnabled;

    @Column(name = "insert_time", columnDefinition = "datetime comment '创建时间'")
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime insertTime;

    @Column(name = "update_time", columnDefinition = "datetime comment '更新时间'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime updateTime;

    @Transient
    @ApiModelProperty(value = "孙模块")
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<ChildBean> children;

}
